#ifndef TEST_BIT_WIN_XML_H
#define TEST_BIT_WIN_XML_H


#include <QDomElement>
#include <QtTest>

#include "bitwin/roles.h"
#include "bitwin/bit_range.h"
#include "bitwin/from_xml.h"

#include "../string_bitwise.h"


Q_DECLARE_METATYPE(QDomElement)
Q_DECLARE_METATYPE(BitWin::BitRange)
Q_DECLARE_METATYPE(BitWin::PGenericBitwise)
Q_DECLARE_METATYPE(BitWin::PRow)


#define VERIFY_TITLES(present, expected) \
    QCOMPARE((present).size(), (expected).size()); \
    for (\
        int VERIFY_TITLES_I = 0; \
        VERIFY_TITLES_I < (present).size(); \
        ++VERIFY_TITLES_I \
    ) \
        QCOMPARE( \
            ((present)[VERIFY_TITLES_I])->title(), \
            (expected)[VERIFY_TITLES_I] \
        );


#define VERIFY_QVARIANT_QSTRING(present, expected) \
    if ((expected).isNull()) \
        QVERIFY(!(present).isValid()); \
    else \
    { \
        QVERIFY((present).isValid()); \
        QVERIFY((present).canConvert<QString>()); \
        QCOMPARE((present).value<QString>(), (expected)); \
    }


class TestBitWinXml: public QObject
{
    Q_OBJECT

    // Helper method: create XML document, given by content,
    // ensure that document is valid, return document element.
    QDomElement createDoc(const QString& content);

private slots:

    void testRowTitles_data();
    void testRowTitles();

    void testRowBehaviour_data();
    void testRowBehaviour();

    void testColumnTitles_data();
    void testColumnTitles();

    void testColumnBehaviour_data();
    void testColumnBehaviour();

    void testMakeModelHeaders_data();
    void testMakeModelHeaders();

    void testMakeModelData_data();
    void testMakeModelData();
};


#endif
